/*
 * Copyright 2007 Stefan Arentz <stefan@arentz.nl>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#import <Cocoa/Cocoa.h>

#import "WebServiceRequest.h"

@class SBJSON;

@interface WebServiceClient : NSObject {
      NSURLConnection* _connection;
      NSMutableData* _responseData;
      id _delegate;
      SBJSON* _json;
      WebServiceRequest* _webServiceRequest;
}

@property(readonly,retain) WebServiceRequest* webServiceRequest;
@property(readonly,retain) id delegate;

//- (id) initWithUrl: (NSURL*) url version: (NSString*) version action: (NSString*) action parameters: (NSDictionary*) parameters delegate: (id) delegate;
//- (id) initWithUrl: (NSURL*) url version: (NSString*) version username: (NSString*) username password: (NSString*) password action: (NSString*) action parameters: (NSDictionary*) parameters delegate: (id) delegate;

- (id) initWithWebServiceRequest: (WebServiceRequest*) request delegate: (id) delegate;
+ (id) webServiceClientWithWebServiceRequest: (WebServiceRequest*) request delegate: (id) delegate;

- (void) start;

+ (NSDictionary*) sendSynchronousRequest: (WebServiceRequest*) request error: (NSError*) error;

@end

@interface NSObject (WebServiceDelegate)

- (void) webServiceClient: (WebServiceClient*) client didFailWithError: (NSError*) error;
- (void) webServiceClient: (WebServiceClient*) client didFinishWithResponse: (NSDictionary*) response;

@end
